/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.univcasa.security.auth;

/**
 *
 * @author i.makhloufi
 */
public class UserRoles {

    private String uid;
    private String role;
    private String errorPage;
    //private Set grantedUrls;
    private String grantedUrls;

    public String getErrorPage() {
        return errorPage;
    }

    public void setErrorPage(String errorPage) {
        this.errorPage = errorPage;
    }

    
    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public void grantResource(String resource){
            //getGrantedUrls().add(resource);
        grantedUrls = resource;
    }
    public String getGrantedUrls() {
        return grantedUrls;
    }

    /*
    public void denyResource(String resource){
        //getGrantedUrls().remove(resource);
        grantedUrls = resource;
    }*/

    public UserRoles() {
        uid="";
        errorPage="";
        grantedUrls = "";
        role ="";
    }

    public UserRoles(String uid, String role, String grantedUrls) {
        this.uid = uid;
        this.role = role;
        this.grantedUrls = grantedUrls;
    }      

    public boolean isGranted(String resource){
        return resource.matches( getGrantedUrls() ) ? true : false ;
    }
}
